#实现文件查找工具
#输入要查找的路径，输入要搜索的文件名（一部分）
#自动的在指定的路径中进行查找~

import os

inputPath =input('请输入要搜索的路径：')  # d:/aaa
pattern = input('请前入要搜索的关键词：')
for dirpath, dirnames, filenames in os.walk(inputPath):
    # print('----------------------------------------------------')
    # print(f'dirpath = {dirpath}')
    # print('dirnames:')
    # for name in dirnames:
    #     print(name)
    # print('filenames:')
    # for name in filenames:
    #     print(name)

    for f in filenames:
        if pattern in f:
            print(f'{dirpath}/{f}')
            # d:/aaa/ccc.txt
            # d:/aaa\bbbb/test.txt


    for f in dirnames:
        if pattern in f:
            print(f'{dirpath}/{f}')
        # d:/aaa/bbbb
        # d:/aaa\bbbb/ddd